﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Text;

namespace Phong_CTSV
{
    public partial class Help : System.Web.UI.Page
    {        
        public string contenHomePage = @"<p> Phần nội dung hướng dẫn </p>";
        public string homeTitle = @"<h1> Hướng dẫn sử dụng Webiste</h1>";
        QuerrySQL querry = new QuerrySQL();
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {                
                string file = System.Web.HttpContext.Current.Server.MapPath("~") + "/help.html";
                if(Session["userName"] != null)
                {
                    string username = Session["userName"].ToString();
                    if (querry.Select_RoleID(username) == 1)
                    {
                        file = System.Web.HttpContext.Current.Server.MapPath("~") + "/helpAdmin.html";
                    }
                }
                if (File.Exists(file))
                {
                    contenHomePage = readHelpHTML(file);
                }                
            }
            catch (Exception ex)
            {
                contenHomePage = ex.Message;
            }
            
        }

        // Readfile 
        private String readHelpHTML(string file)
        {
            StreamReader reader = new StreamReader(file, Encoding.UTF8);
            String content = reader.ReadToEnd();
            reader.Close();
            return content;
        }

    }
}